<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


if ( ! function_exists('echoHtmlStartHeaderBody')) {

    function echoHtmlStartHeaderBody(){
        echo <<<PRINTED
<!doctype html>
<html>
<head>
PRINTED;
        echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
        include_title();
        echoJavascripts();
        include_stylesheets();
        echo <<<PRINTED
</head>
PRINTED;
        echoBody();
    }
}

/**
 * Echo javascripts in head
 * @author Liang Dong
 *
 * @return null
 *
 */
if ( ! function_exists('echoJavascripts')) {
    function echoJavascripts() {
        echo <<<PRINTED
<script type="text/javascript">
var JQUERY = {WeVote: {data: {}, lang: {} } };
</script>
PRINTED;

        include_javascripts();
    }
}

/**
 * Echo body tag
 * @author Liang Dong
 *
 * @return null
 *
 */
if ( ! function_exists('echoBody')) {
    function echoBody() {
        echo <<<PRINTED
<body>
PRINTED;
    }
}

/**
 * Echo inline js in the bottom of page
 * @author Liang Dong
 *
 * @param   array   js_data_resources
 * @param   array   js_lang_resources
 * @return null
 *
 */
if ( ! function_exists('echoInlineJsString')) {
    function echoInlineJsString($js_data_resources=array(), $js_lang_resources=array()) {
        echo '<script type="text/javascript">JQUERY.WeVote.lang=';
        echo json_encode($js_lang_resources);
        echo ';JQUERY.WeVote.data=';
        echo json_encode($js_data_resources);
        echo "</script>\n";
    }
}

/**
 * Echo html end tags
 * @author Liang Dong
 *
 * @param   array   js_data_resources
 * @param   array   js_lang_resources
 * @return null
 *
 */
if ( ! function_exists('echoHtmlEndScript')) {
    function echoHtmlEndScript($js_data_resources=array(), $js_lang_resources=array()) {
        echoInlineJsString($js_data_resources, $js_lang_resources);
        echo <<<PRINTED
</body>
</html>
PRINTED;
    }
}
